import unittest,requests
import allure

@allure.epic("维度系列")
@allure.feature("维度健康")
class wdjk(unittest.TestCase):

    def setUp(self) -> None:
        print('测试开始')

    def tearDown(self) -> None:
        print('测试结束')

    host = 'http://10.59.9.18'
    # 登录
    doctorId = None
    sessionId = None

    @allure.story("登录")
    @allure.title("输入正确的参数，登录成功")
    @allure.severity("blocker")
    @allure.description("提示：登录成功")
    @allure.testcase("https://gitee.com/xiao_gao_xian_sheng/test_case.git")
    @allure.issue("http://127.0.0.1:82/zentao/my.html")
    @allure.link("http://10.59.9.18:4999/web/#/8/150")
    def test_wdjk_01(self):
        r1 = requests.post(url=wdjk.host + '/health/doctor/v1/login',
                           data={'email':'2306398720@qq.com', 'pwd':'lZjdXyj15cOhn1a0yJKsW7o+fw/ogBDzn6CcyPSJUVIMmCPtCs+zuPw'
                                                                    'h7IZkXZiRhJvvjdIz9D2z1jkMOtD/36ddaLFMtQd9xIk0jAaDP1TH/lE'
                                                                    'HvvUPwot6asMGMGkH9EgBPT+4eaYC77BGQBPOASweQZE5KDF8BeN/c0sLfSw='})

        print(r1.json())
        wdjk.doctorId = r1.json()['result']['doctorId']
        print(wdjk.doctorId)
        wdjk.sessionId = r1.json()['result']['sessionId']
        print(wdjk.sessionId)
        # 断言
        self.assertEqual('登录成功', r1.json()['message'])

    # 查询医生的问诊记录列表
    def test_wdjk_02(self):
        r2 = requests.get(url=wdjk.host + '/health/doctor/inquiry/verify/v1/findInquiryRecordList',
                          headers={'doctorId':str(wdjk.doctorId),'sessionId':str(wdjk.sessionId)})
        print(r2.json())
        # 断言
        self.assertEqual('查询成功', r2.json()['message'])

    # 查询医生历史问诊记录列表
    # 聊天记录id
    recordId = None
    def test_wdjk_03(self):
        r3 = requests.get(url=wdjk.host + '/health/doctor/inquiry/verify/v1/findHistoryInquiryRecord',
                          headers={'doctorId': str(wdjk.doctorId), 'sessionId': str(wdjk.sessionId)},
                          params={'page':1,'count':5})
        print(r3.json())
        wdjk.recordId = r3.json()['result'][0]['recordId']
        print(wdjk.recordId)
        # 断言
        self.assertEqual('查询成功', r3.json()['message'])

    # 查询问诊聊天记录
    def test_wdjk_04(self):
        r4 = requests.get(url=wdjk.host + '/health/doctor/inquiry/verify/v1/findInquiryDetailsList',
                          headers={'doctorId': str(wdjk.doctorId), 'sessionId': str(wdjk.sessionId)},
                          params={'recordId':str(wdjk.recordId),'page': 1, 'count': 5})
        print(r4.json())
        # 断言
        self.assertEqual('查询成功', r4.json()['message'])
    # 结束问诊
    def test_wdjk_05(self):
        r5 = requests.put(url=wdjk.host + '/health/doctor/inquiry/verify/v1/endInquiry',
                          headers={'doctorId': str(wdjk.doctorId), 'sessionId': str(wdjk.sessionId)},
                          params={'recordId':str(wdjk.recordId)})
        print(r5.json())
        # 断言
        self.assertIn('问诊已结束', r5.json()['message'])
if __name__ == '__main__':
    unittest.main()


